#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
using namespace std;

class Solution {
public:
	int titleToNumber(string columnTitle) {
		unordered_map<char, int> reflect;
		char alpha = 'A';
		int pass = 1,sum=0;
		for (int i = 0; i < 26; i++) {
			reflect[alpha] = pass;
			alpha++;
			pass++;
		}
		for (int i = 0; i < columnTitle.size(); i++) {
			int num = reflect[columnTitle[i]];
			sum = sum * 26 + num;
		}
		return sum;
	}

	int titleToNumberOptimize(string columnTitle) {
		int sum = 0;
		for (int i = 0; i < columnTitle.size(); i++) 
			sum = sum * 26 + int(columnTitle[i] - 'A'+1);		
		return sum;
	}

};

int main() {
	Solution s;
	s.titleToNumberOptimize("ZY");
}